
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:mybase/windows/TextToastWindow.dart';

class FFWindowTool {

  ///MaterialApp,navigatorObservers需要
  static NavigatorObserver dialogObserver() {
    return FlutterSmartDialog.observer;
  }

  ///MaterialApp,builder需要
  static TransitionBuilder dialogInit() {
    return FlutterSmartDialog.init();
  }

  ///弹文本
  static Future<void> showToastByBottom({
    String? text,
    Duration? displayTime,
    Color? textColor,
    Color? bgColor,
  }) async {
    return await SmartDialog.show(
      clickMaskDismiss: false,
      backDismiss: false,
      displayTime: displayTime ?? const Duration(milliseconds: 1500),
      animationTime: const Duration(milliseconds: 300),
      alignment: Alignment.bottomCenter,
      builder: (builder) {
        return TextToastWindow(
          text: text,
          textColor: textColor,
          bgColor: bgColor,
        );
      },
    );
  }
}
